package educar.gui;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.LayoutManager;
import java.sql.SQLException;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;

//import com.jgoodies.forms.factories.CC;
import educar.controllers.ActividadControllerDoc;
import educar.controllers.CorreccionController;
import educar.controllers.DatosActController;
import educar.controllers.DatosController;
import educar.controllers.IController;
import educar.controllers.LoginController;
import educar.controllers.MateriaController;
import educar.db.JPA;
import educar.models.Session;

public class DocenteActView extends JPanel implements IView {
	 JFrame jfWindow;
	JLabel label1;
	JTextField textField1;
	 JButton button1;
     JButton button2;
     javax.swing.JComboBox jComboBox1;
     String nomMat [];
     
	public DocenteActView() {
		jfWindow = new JFrame();
		Container container = jfWindow.getContentPane();

		setupMainContainer(container);

		jfWindow.pack();
		jfWindow.setVisible(true);
		jfWindow.setResizable(false);
		jfWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	}

	private void setupMainContainer(Container container) {
		container.setLayout((LayoutManager) new BoxLayout(jfWindow
				.getContentPane(), BoxLayout.Y_AXIS));

		((JComponent) container).setBorder(new EmptyBorder(20,70,70, 70));

		JLabel lblWelcome = new JLabel(" Seleccione materia disponible ");
		lblWelcome.setAlignmentX(Component.CENTER_ALIGNMENT);
		lblWelcome.setFont(new Font("Serif", Font.BOLD, 20));
		lblWelcome.setBorder(new EmptyBorder(0, 10, 10, 10));
		container.add(lblWelcome);
		
		
		
		JPA jpa = new JPA();
		try {
			
		nomMat =jpa.getConsulta("materia", "nombre", "codigo=codigo");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		jComboBox1 = new javax.swing.JComboBox();
		jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(nomMat));
	       jComboBox1.setName("jComboBox1"); 
	       JPanel usernamePane2 = new JPanel();
			usernamePane2.setLayout(new BoxLayout(usernamePane2, BoxLayout.LINE_AXIS));
			usernamePane2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));					
			usernamePane2.add(jComboBox1);					
			container.add(usernamePane2);

			  
		
		//---- button1 ----
				
		JButton bact = new JButton("Crear actividad");
		bact.setFont(new Font("Serif", Font.BOLD, 15));
		bact.setAlignmentX(CENTER_ALIGNMENT);
		container.add(bact);
		
		
		JButton bcorrecion = new JButton("Subir correcion");
		bcorrecion.setFont(new Font("Serif", Font.BOLD, 15));
		bcorrecion.setAlignmentX(CENTER_ALIGNMENT);
			container.add(bcorrecion);
			
		LoginListener buttonListener = new LoginListener();
			IController loginController = new DatosActController();
			loginController.setView(this);
			buttonListener.associate(bact, loginController);
			
			LoginListener buttonListener2 = new LoginListener();
			IController loginController2 = new CorreccionController();
			loginController2.setView(this);
			buttonListener2.associate(bcorrecion, loginController2);
		
		
	}
	
	
	 
	 public void present(String model) {
			JOptionPane.showMessageDialog(null, model);
		}

	 public String getMateria(){
			
         return (String) jComboBox1.getSelectedItem();
     } 	

	
	public static void main(String args[]) {
		
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
				try {
					UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
				} catch (Exception ex) {
					// ignore
				}
               javax.swing.JFrame frame = new javax.swing.JFrame("Datos");
                frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
                frame.getContentPane().add(new DocenteActView());
                frame.pack();
                frame.setVisible(false);
              
               
            }
        });
    }
	
	
}